<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet  [
	<!ENTITY nbsp   "&#160;">
	<!ENTITY agrave "&#224;">
	<!ENTITY egrave "&#232;">
	<!ENTITY eacute "&#233;">
	<!ENTITY ocirc	"&#244;">
	<!ENTITY copy   "&#169;">
	<!ENTITY reg    "&#174;">
	<!ENTITY trade  "&#8482;">
	<!ENTITY mdash  "&#8212;">
	<!ENTITY ldquo  "&#8220;">
	<!ENTITY rdquo  "&#8221;"> 
	<!ENTITY pound  "&#163;">
	<!ENTITY yen    "&#165;">
	<!ENTITY euro   "&#8364;">
]>

<xsl:stylesheet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="babel-transform-schema.xsd" 
 xmlns:bw="http://tice2.univ-reunion.fr/babelweb"
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns="http://www.w3.org/1999/xhtml"
 exclude-result-prefixes="bw xsi xsl xs"
 version="1.0">
	<!--http://www.w3.org/1999/XSL/Transform -->
	
<!--	<xsl:import href="manifest-manager.xsl"/>-->
	<xsl:import href="navigation/navigation.xsl"/>
	<xsl:import href="conf/babel-web-conf.xsl"/>
	
	<xsl:param name="modulePath">
		<xsl:variable name="module" select="//assessmentItem/@module"/>
		<xsl:choose>
			<xsl:when test="starts-with($module,'m10')">
				<xsl:value-of select="$module_10_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m1')">
				<xsl:value-of select="$module_1_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m2')">
				<xsl:value-of select="$module_2_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m3')">
				<xsl:value-of select="$module_3_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m4')">
				<xsl:value-of select="$module_4_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m5')">
				<xsl:value-of select="$module_5_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m6')">
				<xsl:value-of select="$module_6_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m7')">
				<xsl:value-of select="$module_7_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m8')">
				<xsl:value-of select="$module_8_path"/>
			</xsl:when>
			<xsl:when test="starts-with($module,'m9')">
				<xsl:value-of select="$module_9_path"/>
			</xsl:when>
			
		</xsl:choose>
	</xsl:param>
	
	<xsl:template match="/">
		
		<xsl:call-template name="page-navigation-fil"/>
		
		<xsl:apply-templates select="//assessmentItem"/>
		
		<xsl:if test="not(starts-with(//assessmentItem/@identifier,'intro'))">
			<xsl:call-template name="page-navigation">
				<xsl:with-param name="class" select="'bottom-nav'"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="assessmentItem">
		
		<!--These should be loaded for the interactivity to work. They are delegated to the template holding the generated file.
			<link href="styles/style.css" rel="stylesheet" type="text/css"/>
			<script type="text/javascript" src="scripts/jquery-1.3.1.min.js"/>
			<script type="text/javascript" src="scripts/jquery-ui-personalized-1.6rc6.min.js"/>
			<script type="text/javascript" src="scripts/jquery.tooltip.pack.js"/>
			<script type="text/javascript" src="scripts/jquery.draw.js"/>
			<script type="text/javascript" src="scripts/jquery.selectboxes.js"/>
			<script type="text/javascript" src="scripts/mash.js"/>-->
		<div id="global">
			<h2 id="exotitle"><xsl:value-of select="@title"/></h2>
			<xsl:call-template name="run">
				<xsl:with-param name="correct-answers" select="responseDeclaration"/>
				<xsl:with-param name="content" select="itemBody"/>
			</xsl:call-template>
		</div>
	</xsl:template>

	<xsl:template name="run">
		<xsl:param name="correct-answers"/>
		<xsl:param name="content"/>

		<div class="answer-set">
			<ul>
				<xsl:apply-templates select="$correct-answers"/>
			</ul>
			<p id="baseType">
				<xsl:value-of select="$correct-answers/@baseType"/>
			</p>
			<p id="mode"><xsl:value-of select="$correct-answers/@mode"/></p>
			<p id="feedbackType">
				<xsl:value-of select="$correct-answers/@feedbackType"/>
			</p>
			<p id="lang">
				<xsl:value-of select="//assessmentItem/@lang"/>
			</p>
		</div>
		

		<div class="exos">
			<xsl:apply-templates select="$content"/>
			<!-- will apply template to itembody content-->
		</div>

		<div id="correction">
		</div>
		
	</xsl:template>

	<xsl:template match="correctionRequest" name="correction">
		<div id="correction">
			<form method="get" action="">
				<input name="correction" value="Corrigé" onclick="" type="submit"/>
			</form>
		</div>
		<div id="reinit">
			<form method="get" action="">
				<input name="reinit" value="Réinitialiser" onclick="" type="submit"/>
			</form>
		</div>
	</xsl:template>

	<!-- **************************************
		Introduction with popups for redirection
		************************************** -->
	<xsl:template match="simpleText">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="toActivity">
		<span class="hoverItem">
			<xsl:apply-templates select="init" mode="hover"/>
			<xsl:apply-templates select="description" mode="hidden"/>
		</span>
	</xsl:template>

	<xsl:template match="init" mode="hover">
		<xsl:variable name="link" select="concat(parent::node()/@id,'.html')"/>
		<a name="{@id}" class="initHover" href="{$link}">
			<xsl:apply-templates/>
		</a>
	</xsl:template>

	<xsl:template match="description" mode="hidden">

		<span id="{@id}" class="hover-content invisible {@class}">
			<xsl:apply-templates/>
		</span>
	</xsl:template>
	
	<xsl:template match="toPool">
		<xsl:variable name="currentName" select="@name"/>
		<xsl:variable name="currentLang" select="//assessmentItem/@lang"/>
		<br/>
		<a href="{$modulePath}/{//resources/pool[@id= $currentName]/descendant::resource[1]/@href}">
			<xsl:copy-of xml:space="preserve" select="@*[name(.) != 'href']"/>
			<xsl:apply-templates/>
		</a>
	</xsl:template>
	
	<xsl:template match="toActivityDirect">
		<xsl:variable name="currentid" select="@id"/>
		
		<a href="{$modulePath}/{//resource[@identifier=$currentid]/@href}"><xsl:value-of select="text()"/></a>
	</xsl:template>
	
	<!-- **************************************
		persistent popups
		************************************** -->
	
	<xsl:template match="popup">
		<xsl:choose>
			<xsl:when test="@mode='noautoclose'">
				<span class="hoverItemNoAutoClose">
					<xsl:apply-templates select="init"/>
					<xsl:apply-templates select="description"/>
				</span>
			</xsl:when>
			<xsl:otherwise>
				<span class="hoverItem">
					<xsl:apply-templates select="init"/>
					<xsl:apply-templates select="description"/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="init">
		<xsl:variable name="link" select="concat(parent::node()/@id,'.html')"/>
		<xsl:variable name="mode" select="parent::node()/@mode"/>
		<xsl:choose>
			<xsl:when test="$mode='noautoclose'">
				<a name="{@id}" class="initHoverNoAutoClose" href="{$link}">
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<a name="{@id}" class="initHover" href="{$link}">
					<xsl:apply-templates/>
				</a>
			</xsl:otherwise>
		</xsl:choose>
		
		
	</xsl:template>
	
	<xsl:template match="description">
		<div id="{@id}" class="hover-content invisible {@class}">
			<xsl:apply-templates/>
		</div>
	</xsl:template>
	
	
	
	
	<!-- **************************************
		on-hover feedbacks / hints
		************************************** -->
	<xsl:template match="text-hint">
		<a href="" name="{@id}" class="bwhint">&nbsp;?&nbsp;</a>
		<span class="invisible" id="{@id}">
			<xsl:apply-templates/>
		</span>
	</xsl:template>
	
	<xsl:template match="image-hint">
		<a href="" name="{@id}" class="img-hint">
			<xsl:apply-templates select="hint-init"/>
		</a>
		<span class="invisible" id="{@id}">
			<xsl:apply-templates select="hover"/>
		</span>
	</xsl:template>
	

	<!--<xsl:template match="gapText">
	</xsl:template>-->
	
	
	<!-- **************************************
		group sense and pressed vowel
		************************************** -->
	
	<xsl:template match="groupsense">
		<span name="sense{@identifier}" class="senseseparator cursorcross">
			<span id="sense{@identifier}" class="feedback invisible" name="{@outcome}"><xsl:value-of select="@feedback"/></span>
		</span>
	</xsl:template>
	
	<xsl:template match="stressedvowel">
		<span name="stressed{@identifier}" class="stressedvowel cursorcross">
			<span class="content"><xsl:apply-templates select="text()"/></span>
			<span id="stressed{@identifier}" class="feedback invisible" name="{@outcome}"><xsl:value-of select="@feedback"/></span>
		</span>
	</xsl:template>
	

	<!-- **************************************
		gapText multi behaviour
		************************************** -->

	<xsl:template match="gapText">
		<xsl:choose>
			<xsl:when test="@mode='drag'">
				<span id="{@identifier}" class="block {@class}">
					<xsl:apply-templates/>
				</span>
			</xsl:when>
			<xsl:when test="@mode='drag-helper'">
				<span id="{@identifier}" class="block-i {@class}">
					<xsl:apply-templates/>
				</span>
			</xsl:when>
			<xsl:when test="@mode='drag-hidden'">
				<span id="{@identifier}" class="block-h {@class}">
					<xsl:apply-templates/>
				</span>
			</xsl:when>
			<xsl:when test="@mode='drag-ball'">
				<div id="{@identifier}" class="block-ball {@class}">
					<xsl:apply-templates/>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<!--<span id="{@identifier}"><xsl:value-of select="text()"></xsl:value-of></span>-->
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="dragImage">
		<xsl:choose>
			<xsl:when test="@mode='drag'">
				<img id="{@identifier}" class="block {@class}">
					<xsl:attribute name="src">
						<xsl:choose>
						<xsl:when test="img/@type='local'">
								<xsl:value-of select="concat('/babel-data/images/',//assessmentItem/@module,'/',img/@src)"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="img/@src"/>
						</xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
					<xsl:copy-of xml:space="preserve" select="img/@*[name(.) = 'alt' and name(.)='title' ]"/>	
				</img>
			</xsl:when>
			<xsl:when test="@mode='drag-helper'">
				<img id="{@identifier}" class="block-i {@class}"><xsl:attribute name="src">
					<xsl:choose>
						<xsl:when test="img/@type='local'">
							<xsl:value-of select="concat('/babel-data/images/',//assessmentItem/@module,'/',img/@src)"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="img/@src"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
					<xsl:copy-of xml:space="preserve" select="img/@*[name(.) = 'alt' and name(.)='title' ]"/>
				</img>
			</xsl:when>
			<xsl:when test="@mode='drag-hidden'">
				<img id="{@identifier}" class="block-h {@class}"><xsl:attribute name="src">
					<xsl:choose>
						<xsl:when test="img/@type='local'">
							<xsl:value-of select="concat('/babel-data/images/',//assessmentItem/@module,'/',img/@src)"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="img/@src"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
					<xsl:copy-of xml:space="preserve" select="img/@*[name(.) = 'alt' and name(.)='title' ]"/>	
				</img>
			</xsl:when>
		</xsl:choose>
		
	</xsl:template>
	

	<!-- **************************************
		feedback inline
		************************************** -->

	<xsl:template match="feedbackInline">
		<xsl:choose>
			<xsl:when test="@showHide='hide'">
				<a href="" name="{@identifier}" class="hint">&nbsp;?</a>&nbsp; <div
					class="invisible" id="{@identifier}">
					<xsl:apply-templates select="negativeFeedback|negativeFeedbackFor"/>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<div>
					<xsl:apply-templates/>
				</div>
			</xsl:otherwise>

		</xsl:choose>
	</xsl:template>


	<!-- **************************************
		gap grouped and spread 
		************************************** -->

	<xsl:template match="gapMatchInteractionSpread">
		<xsl:apply-templates select="prompt"/>

		<xsl:call-template name="answerGroupMatchSpread">
			<xsl:with-param name="batches" select="blockquote/batch"/>
		</xsl:call-template>
		
		<xsl:apply-templates select="blockquote/globalFeedbackPos"/>
		<xsl:apply-templates select="blockquote/globalFeedbackNeg"/>
	</xsl:template>

	<xsl:template name="answerGroupMatchSpread">
		<xsl:param name="batches"/>

		<xsl:for-each select="$batches">
			<xsl:variable name="groupnum" select="@value"/>
			<div class="answergroup">
				<!--<p><xsl:value-of select="text()"/></p>-->
				<xsl:apply-templates select="*|text()"/>
				<div name="for-{$groupnum}">
					<xsl:call-template name="ascending-alpha-sort-dnd">
						<xsl:with-param name="items" select="//gapText[@group=$groupnum]"/>
					</xsl:call-template>
				</div>
			</div>
		</xsl:for-each>
	</xsl:template>

	<!-- **************************************
		gap match (dnd)
		************************************** -->

	<xsl:template match="gapMatchInteraction">
		<xsl:apply-templates select="prompt"/>
		<xsl:apply-templates select="blockquote"/>

		<div class="listing gaptext">
			<div>
				<xsl:call-template name="ascending-alpha-sort-dnd">
					<xsl:with-param name="items" select="gapText"/>
				</xsl:call-template>
			</div>
		</div>
	</xsl:template>

	<xsl:template match="gap">
		<span class="gap drop {@class}" id="{@identifier}"
			><xsl:apply-templates/>..........</span>
	</xsl:template>
	
	<xsl:template match="dropZone">
		<div class="drop-camo blocksize" id="{@identifier}">
			<xsl:apply-templates/>
		</div>
	</xsl:template>

	<xsl:template name="ascending-alpha-sort-dnd">
		<xsl:param name="items"/>
		<xsl:for-each select="$items">
			<xsl:sort data-type="text" order="ascending" case-order="lower-first" select="."/>
			<span class="block {@class}" id="{@identifier}">
				<xsl:value-of select="text()"/>
				<xsl:apply-templates select="hint/text-hint"/>
				<xsl:apply-templates select="feedback"/>
			</span>
		</xsl:for-each>
	</xsl:template>

	<!-- **************************************
		sort interaction
		************************************** -->
	<xsl:template match="sortInteraction">
		<div class="sortInteract {@class}">
			<xsl:apply-templates select="prompt"/>
			<div class="answergroup" id="answergroup"></div>
			<xsl:apply-templates select="blockquote"/>
		</div>
	</xsl:template>
	
	<xsl:template match="randomize-position">
		<div class="random {@class}">
			<xsl:apply-templates/>
		</div>
	</xsl:template>

	<!-- <xsl:template match="gapText">
	</xsl:template> -->


<!-- MODIFICATION TO VERIFY -->
	<xsl:template match="feedback">
		<span class="feedback invisible">
			<xsl:choose>
				<xsl:when test="positiveFeedback">
					<span class="positive">
						<xsl:apply-templates select="positiveFeedback"/>
					</span>
				</xsl:when>
			</xsl:choose>
			<xsl:choose>
				<xsl:when test="negativeFeedback">
					<span class="negative">
						<xsl:apply-templates select="negativeFeedback"/>
					</span>
				</xsl:when>
			</xsl:choose>
			<xsl:choose>
				<xsl:when test="negativeFeedbackFor">
					<xsl:for-each select="negativeFeedbackFor">
						<span class="negative feebackForItem" name="{@name}">
							<xsl:apply-templates select="."/>
						</span>
					</xsl:for-each>
					
				</xsl:when>
			</xsl:choose>
		</span>
	</xsl:template>

	<!-- **************************************
		sort and match interaction (mixed exo)
		************************************** -->
	<xsl:template match="sortMatchInteraction">
		<div class="sortInteract {@class}">
			<xsl:apply-templates select="prompt"/>
			<div class="matchbox">
				<xsl:apply-templates select="blockquote"/>
			</div>
		</div>
	</xsl:template>


	<xsl:template match="matchable">
		<xsl:choose>
			<xsl:when test="@type='start'">
				<div class="matchstart" id="{@id}">
					<xsl:apply-templates/>
				</div>
			</xsl:when>
			<xsl:when test="@type='end'">
				<div class="matchend" id="{@id}">
					<xsl:apply-templates/>
				</div>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<!-- **************************************
		table sort 
		************************************** -->

	<xsl:template match="tableSortInteraction">
		<xsl:apply-templates select="prompt"/>

		<xsl:apply-templates select="blockquote"/>
	</xsl:template>

	<xsl:template match="tableSort">

		<xsl:call-template name="batchTableSort">
			<xsl:with-param name="fields" select="field"/>
			<xsl:with-param name="batches" select="batch"/>
			<xsl:with-param name="width" select="count(./field)"/>
		</xsl:call-template>
	</xsl:template>

	<xsl:template name="batchTableSort">
		<xsl:param name="fields"/>
		<xsl:param name="batches"/>
		<xsl:param name="width"/>

		<xsl:for-each select="$batches">
			<div class="batchsort">
				<xsl:call-template name="ascending-alpha-sort-dndg">
					<xsl:with-param name="items" select="./gapText"/>
				</xsl:call-template>
			<table class="listing {@class} sortable">
				<thead>
					<tr>
						<xsl:apply-templates select="$fields" mode="tableSort"/>
					</tr>
				</thead>
				<tbody>
					<tr>
						<xsl:call-template name="gapTextBlank">
							<xsl:with-param name="text" select="./gapText"/>
							<xsl:with-param name="group" select="@value"/>
						</xsl:call-template>
						<xsl:choose>
							<xsl:when test="count(./gapText) &lt; $width ">
								<xsl:variable name="td"><td></td></xsl:variable>
								<xsl:call-template name="for.loop">
									<xsl:with-param name="content" select="$td"/>
									<xsl:with-param name="i">1</xsl:with-param>
									<xsl:with-param name="count" select="$width - count(./gapText)"/>
								</xsl:call-template>
							</xsl:when>
						</xsl:choose>
					</tr>
				</tbody>
			</table>
			
				<xsl:apply-templates select="feedback"/>
			</div>
		</xsl:for-each>
	</xsl:template>
	
	<xsl:template match="globalFeedbackPos">
		<div class="invisible globalFB"><xsl:apply-templates/></div>
	</xsl:template>
	
	<xsl:template match="globalFeedbackNeg">
		<div class="invisible globalFBNeg"><xsl:apply-templates/></div>
	</xsl:template>

	<xsl:template name="gapTextBlank">
		<xsl:param name="text"/>
		<xsl:param name="group"/>
		<xsl:for-each select="$text">
			<xsl:variable name="id" select="concat('G',$group,'-', position())"/>
			<td class="drop-camo {@class}" id="{$id}">
			</td>
		</xsl:for-each>
	</xsl:template>


	<xsl:template match="field" mode="tableSort">
		<th id="{@identifier}">
			<xsl:value-of select="@name"/>
		</th>

	</xsl:template>


	<!-- **************************************
		gap match with grouped answers (dnd)
		************************************** -->

	<xsl:template name="answerGroupMatch">
		<xsl:param name="groups"/>

		<xsl:for-each select="$groups">
			<xsl:variable name="groupnum" select="@identifier"/>
			<div class="answergroup">
				<p>
					<xsl:value-of select="."/>
				</p>
				<div>
					<xsl:call-template name="ascending-alpha-sort-dndg">
						<xsl:with-param name="items" select="//gapText[@group=$groupnum]"/>
					</xsl:call-template>
				</div>
			</div>
		</xsl:for-each>
	</xsl:template>
	
	<xsl:template name="answerGroupMatchAuto">
		<xsl:for-each select="//answerGroup">
			<xsl:variable name="groupnum" select="@identifier"/>
			<div class="answergroup">
				<p>
					<xsl:value-of select="."/>
				</p>
				<div>
					<xsl:call-template name="ascending-alpha-sort-dndg">
						<xsl:with-param name="items" select="//gapText[@group=$groupnum]"/>
					</xsl:call-template>
				</div>
			</div>
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="gapMatchInteractionGrouped">
		<xsl:apply-templates select="prompt"/>
		<xsl:apply-templates select="blockquote"/>

		<!--<xsl:call-template name="answerGroupMatch">
			<xsl:with-param name="groups" select="answerGroup"/>
		</xsl:call-template>-->
	</xsl:template>
	
	<xsl:template match="placeAnswers">
		<xsl:call-template name="answerGroupMatchAuto"/>
	</xsl:template>

	<xsl:template name="ascending-alpha-sort-dndg">
		<xsl:param name="items"/>
		<div class="answergroup">
		<xsl:for-each select="$items">
			<xsl:sort select="text()"/>
			<span class="block {@class} {@identifier}" id="{@identifier}">
				<xsl:value-of select="text()"/>
				<xsl:apply-templates select="hint"/>
				<xsl:apply-templates select="feedback"/>
			</span>
		</xsl:for-each>
		</div>
	</xsl:template>
	
	<!-- **************************************
		imageMatchInteraction
		************************************** -->
	
	<xsl:template match="imageMatchInteraction">
		<xsl:apply-templates select="prompt"/>
		<xsl:apply-templates select="blockquote"/>
	</xsl:template>
	
	<xsl:template match="map">
		<map name="{@name}">
			<xsl:apply-templates select="area"/>
		</map>
	</xsl:template>
	
	<xsl:template match="area">
		<area shape="{@shape}" coords="{@coords}" id="{@identifier}" name="{@name}"/>
	</xsl:template>
	

	<!-- **************************************
		fill in (text)
		************************************** -->
	<xsl:template match="fillinInteraction">
		<xsl:apply-templates select="prompt"/>
		<xsl:apply-templates select="blockquote" mode="fillin"/>
		<xsl:apply-templates select="blockquote/globalFeedbackPos"/>
		<xsl:apply-templates select="blockquote/globalFeedbackNeg"/>
	</xsl:template>
	
	<xsl:template match="blockquote" mode="fillin">
		<xsl:apply-templates mode="fillin"/>
	</xsl:template>

	<xsl:template match="p" mode="fillin">
		<p class="{@class}">
			<!--<xsl:if test="@class">
				<xsl:attribute name="class" select="@class"/>
			</xsl:if>-->
			<xsl:apply-templates mode="fillin"/>
		</p>
	</xsl:template>
	
	<xsl:template match="extLink" mode="fillin">
		<a href="{@href}" target="_blank" title="{@title}">
			<xsl:value-of select="."/>
		</a>
	</xsl:template>
	
	<xsl:template match="newline" mode="fillin">
		<br/>
	</xsl:template>
	
	<xsl:template match="gap" mode="fillin">
		<span class="gap {@class}">
			<input type="text" class="fillin" id="{@id}"/>
			<xsl:apply-templates/>
		</span>
<!--		<xsl:apply-templates select="bw:hint" mode="fillin"/>-->
	</xsl:template>
	
	<xsl:template match="text-hint" mode="fillin">
		<a href="" name="{@id}" class="bwhint {@class}">&nbsp;?&nbsp;</a>
		<span class="invisible" id="{@id}">
			<xsl:apply-templates/>
		</span>
	</xsl:template>
	
	<xsl:template match="image-hint" mode="fillin">
		<a href="" name="{@id}" class="img-hint {./hint-init/@class}">
			<xsl:apply-templates select="hint-init"/>
		</a>
		<span class="invisible" id="{@id}">
			<xsl:apply-templates select="hover"/>
		</span>
	</xsl:template>
	
	<xsl:template match="nearMatch"  mode="fillin">
		<span class="nearmatch invisible" id="{@value}">
			<xsl:value-of select="@response"/>
		</span>
	</xsl:template>
	
	<xsl:template match="table"  mode="fillin">
		<xsl:choose>
			<xsl:when test="@class = 'nottable'">
				<table class="{@class}">
					<xsl:apply-templates select="tr"  mode="fillin"/>
				</table>
			</xsl:when>
			<xsl:otherwise>
				<table class="listing {@class}">
					<xsl:apply-templates select="tr"  mode="fillin"/>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="tr"  mode="fillin">
		<xsl:choose>
			<xsl:when test="position() mod 2 = 0">
				<tr class="even {@class}">
					<xsl:apply-templates  mode="fillin"/>
				</tr>
			</xsl:when>
			<xsl:otherwise>
				<tr class="odd {@class}">
					<xsl:apply-templates  mode="fillin"/>
				</tr>
			</xsl:otherwise>
			
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="td"  mode="fillin">
		<td>
			<xsl:copy-of xml:space="preserve" select="@*"/>
			<xsl:apply-templates  mode="fillin"/>
		</td>
	</xsl:template>
	
	<xsl:template match="th"  mode="fillin">
		<th>
			<xsl:copy-of xml:space="preserve" select="@*"/>
			<xsl:apply-templates  mode="fillin"/>
		</th>
	</xsl:template>
	
	<xsl:template match="div" mode="fillin">
		<div class="{@class}">
			<xsl:apply-templates mode="fillin"/>
		</div>
	</xsl:template>
	
	<xsl:template match="img" mode="fillin">
		<xsl:choose>
			<xsl:when test="@type='local'"> <!--and @height!=''"-->
				<img src="/babel-data/images/{//assessmentItem/@module}/{@src}">
					<xsl:copy-of xml:space="preserve" select="@*[name(.) != 'src' and name(.) != 'type' ]"/>					
				</img>
			</xsl:when>
			<!--<xsl:when test="@type='local'">
				<img src="/babel-data/images/{//assessmentItem/@module}/{@src}" title="{@title}" class="{@class}"/>
				</xsl:when>-->
			<xsl:otherwise>
				<img src="{@src}" title="{@title}" alt="{@alt}"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="globalFeedbackPos" mode="fillin">  <!--TO AVOID REPETITION-->
	</xsl:template>
	
	<xsl:template match="globalFeedbackNeg" mode="fillin"> <!--TO AVOID REPETITION-->
	</xsl:template>
	
	<!--<xsl:template match="bw:hint" mode="fillin">
		<xsl:apply-templates/>
	</xsl:template>-->

	<xsl:template match="spacer" mode="fillin">
		<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
	</xsl:template>
	
	<xsl:template match="cite" mode="fillin">
		<cite>
			<xsl:apply-templates/>
		</cite>
	</xsl:template>
	
	<xsl:template match="em" mode="fillin">
		<em>
			<xsl:apply-templates/>
		</em>
	</xsl:template>
	
	<xsl:template match="span" mode="fillin">
		<span class="{@class}">
			<xsl:apply-templates/>
		</span>
	</xsl:template>
	
	<xsl:template match="autohint">
		<span class="autohint" name="{parent::node()/@id}"/>
	</xsl:template>
	
	<xsl:template match="autohint-shuffle">
		<span class="autohint shuffle" name="{@name}"/>
	</xsl:template>
	
	<!--<xsl:template match="div" mode="fillin">
		<div>
			<xsl:for-each select="@*">
				<xsl:attribute name="{name()}">
					<xsl:apply-templates/>
				</xsl:attribute>
			</xsl:for-each>
			<xsl:apply-templates/>
		</div>
	</xsl:template>-->
	
	<xsl:template match="spacer">
		<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
	</xsl:template>
	

	<!-- **************************************
		inline choice selection
		************************************** -->
	<xsl:template match="inlineChoiceInteraction">
		<span>
			<select class="inputbox inline-exe" size="1">
				<xsl:choose>
					<xsl:when test="./default">
						<option value="-1">- <xsl:value-of select="default/text()"/> -</option>
					</xsl:when>

					<xsl:otherwise>
						<option value="-1"> - ? -</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:apply-templates select="inlineChoice"/>
			</select>

			<xsl:choose>
				<xsl:when test="feedbackInline">
					<span class="feedback invisible">
						<xsl:choose>
							<xsl:when test="feedbackInline/positiveFeedback">
								<xsl:call-template name="feedbackInline-inlineChoice">
									<xsl:with-param name="node"
										select="feedbackInline/positiveFeedback"/>
									<xsl:with-param name="mode" select="'positive'"/>
								</xsl:call-template>
							</xsl:when>
						</xsl:choose>
						<xsl:choose>
							<xsl:when test="feedbackInline/negativeFeedback">
								<xsl:call-template name="feedbackInline-inlineChoice">
									<xsl:with-param name="node"
										select="feedbackInline/negativeFeedback"/>
									<xsl:with-param name="mode" select="'negative'"/>
								</xsl:call-template>
							</xsl:when>
						</xsl:choose>
						<xsl:choose>
							<xsl:when test="feedbackInline/negativeFeedbackFor">
								<xsl:for-each select="feedbackInline/negativeFeedbackFor">
									<xsl:call-template name="feedbackInline-inlineChoice">
										<xsl:with-param name="node"
											select="."/>
										<xsl:with-param name="mode" select="'negative'"/>
										<xsl:with-param name="class" select="'feebackForItem'"/>
										<xsl:with-param name="name" select="feedbackInline/negativeFeedbackFor/@name"/>
									</xsl:call-template>
								</xsl:for-each>
							</xsl:when>
						</xsl:choose>
					</span>
				</xsl:when>
			</xsl:choose>
		</span>
	</xsl:template>
	
	<xsl:template name="feedbackInline-inlineChoice">
		<xsl:param name="node"/>
		<xsl:param name="mode"/>
		<xsl:param name="class" select="narf"/>
		<xsl:param name="name" select="generate-id()"/>
		<span class="{$mode} {$class}" name="{@name}">
			<xsl:apply-templates select="$node"/>
		</span>
	</xsl:template>

	<xsl:template match="inlineChoice">
		<option value="{@identifier}">
			<xsl:value-of select="."/>
		</option>
	</xsl:template>
	
	<xsl:template match="multichoice">
		<xsl:variable name="group" 
		select="concat('g', count(ancestor-or-self::node()/preceding-sibling::node()[descendant-or-self::multichoice]//multichoice)+1)"/>
		
		<xsl:call-template name="item-multichoice">
			<xsl:with-param name="items" select="item"/>
			<xsl:with-param name="group" select="$group"/>
			<xsl:with-param name="fb" select="feedback"/>
			<xsl:with-param name="display" select="@display"/>
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="item-multichoice">
		<xsl:param name="items"/>
		<xsl:param name="group"/>
		<xsl:param name="fb"/>
		<xsl:param name="display" select="default"/>
		
		<xsl:variable name="multimode" select="//responseDeclaration/@mode"/>
		<xsl:choose>
			<xsl:when test="$multimode!=''">
				<span class="multi">
					<xsl:for-each select="$items">
						<span class="multiItem">
							<input type="{$multimode}" name="{$group}" id="{$group}-{position()}"/><xsl:apply-templates/>
							<xsl:if test="not($display)">
								<br/>
							</xsl:if>
							<xsl:if test="$display='inline'"></xsl:if>
						</span>
					</xsl:for-each>
					<xsl:apply-templates select="$fb"/>
				</span>
			</xsl:when>
			<xsl:otherwise>
				<span class="multi">
					<xsl:for-each select="$items">
						<span class="multiItem">
							<input type="checkbox" name="{$group}" id="{$group}-{position()}"/><xsl:apply-templates/>
							<xsl:if test="$display!='inline'">
								<br/>
							</xsl:if>
						</span>
					</xsl:for-each>
					<xsl:apply-templates select="$fb"/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
		
	</xsl:template>

	<!-- answer set -->
	<xsl:template match="correctResponse">
		<xsl:for-each select="value">
			<li>
				<xsl:value-of select="."/>
			</li>
		</xsl:for-each>
	</xsl:template>

	<!-- Sort function -->
	<xsl:template name="ascending-alpha-sort">
		<xsl:param name="items"/>
		<xsl:for-each select="$items">
			<xsl:sort select="."/>
			<td>
				<div class="block {@class} {@identifier}">
					<xsl:value-of select="."/>
				</div>
			</td>
		</xsl:for-each>
	</xsl:template>


	<xsl:template match="bw:sound">
		<xsl:variable name="module" select="//assessmentItem/@module"/>
		<xsl:variable name="lang" select="//assessmentItem/@lang"/>
		<xsl:choose>
			<xsl:when test="@type='long'">
				<object type="application/x-shockwave-flash" data="/babel-data/audio/player_mp3_maxi.swf"
					width="150" height="20">
					<param name="movie" value="/babel-data/audio/player_mp3_maxi.swf"/>
					<param name="FlashVars"
						value="mp3=/babel-data/audio/{$lang}/{$module}/{@src}&amp;width=150&amp;height=20" 
						
					/>
				</object>
			</xsl:when>
			<xsl:otherwise>
				<object type="application/x-shockwave-flash" data="/babel-data/audio/player_mp3_maxi.swf"
					width="20" height="18">
					<param name="movie" value="/babel-data/audio/player_mp3_maxi.swf"/>
					<param name="FlashVars"
						value="mp3=/babel-data/audio/{$lang}/{$module}/{@src}&amp;bodycolor=f39024&amp;buttoncolor=bbbbbb&amp;buttonwidth=20&amp;showslider=0&amp;width=20&amp;height=18"
					/>
				</object>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="flashMedia">
		
		<div class="flash-media" name="{@id}">
			<!--<form name="flash-media-form" onsubmit="return false;">
				<input id="flash-start" type="button" value="{@cue}"/>
			</form>-->
		<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
			codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" 
			width="{@width}" height="{@height}" id="{@id}" align="middle">
			
			<param name="allowScriptAccess" value="sameDomain" />
			<param name="allowFullScreen" value="false" />
			<param name="movie" value="/babel-data/flash/{@url}" />
			<param name="quality" value="high" />
			<PARAM NAME="FlashVars" VALUE="langfile=/babel-data/flash/{@langfile}"/>
			<param name="bgcolor" value="#ffffff" />
			<embed src="/babel-data/flash/{@url}" quality="high" bgcolor="#ffffff"
				width="{@width}" height="{@height}" name="{@id}" align="middle"
				FlashVars="langfile=/babel-data/flash/{@langfile}"
				allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" 
				pluginspage="http://www.macromedia.com/go/getflashplayer" />
		</object>
			
		</div>
	</xsl:template>

	<!-- logo -->
	<xsl:template match="logo">
		<img src="images/logo.png" class="{@class}" alt="logo"/>
	</xsl:template>

	<xsl:template match="guideline">
		<div class="guideline"/>
	</xsl:template>

	<xsl:template match="prompt">
		<div class="prompt">
			<xsl:apply-templates/>
		</div>
	</xsl:template>

	<!-- 
	The following are mostly html tags.
	Possible classes (described in the css) for <p>, <i> and <span> are : 
		right, center, strong, strike, red, citation.
	-->


	<xsl:template match="p">
		<p>
			<xsl:copy-of xml:space="preserve" select="@*"/> 
			<xsl:apply-templates/>
		</p>
	</xsl:template>

	<xsl:template match="i">
		<i class="{@class}">
			<xsl:apply-templates/>
		</i>
	</xsl:template>

	<xsl:template match="span">
		<span>
			<xsl:copy-of xml:space="preserve" select="@*"/>
			<xsl:apply-templates/>
		</span>
	</xsl:template>


	<!-- A <list> tag can only have a <p> child. Consider changing this if "bigger" elements are needed,
		or use the "mode" attribute for matching-->
	<xsl:template match="list">
		<ul class="enum {@class}">
			<xsl:for-each select="p">
				<li>
					<p class="{@class}">
						<xsl:apply-templates/>
					</p>
				</li>
			</xsl:for-each>
		</ul>
	</xsl:template>
	
	<xsl:template match="div">
		<div>
			<xsl:for-each select="@*">
				<xsl:attribute name="{name()}">
					<xsl:value-of select="."/>
				</xsl:attribute>
			</xsl:for-each>
			<xsl:apply-templates/>
		</div>
	</xsl:template>


		<!--<xsl:template match="*">
			<xsl:element name="{name()}">
				<xsl:for-each select="@*">
					<xsl:attribute name="{name()}">
						<xsl:value-of select="."/>
					</xsl:attribute>
				</xsl:for-each>
				<xsl:apply-templates select="*|text()"/>
			</xsl:element>
		</xsl:template>-->

	<xsl:template match="table">
		<xsl:choose>
			<xsl:when test="@class = 'nottable'">
				<table class="{@class}">
					<xsl:copy-of xml:space="preserve" select="@*[name(.) != 'class']"/>
					<xsl:apply-templates select="tr"/>
				</table>
			</xsl:when>
			<xsl:otherwise>
				<table class="listing {@class}">
					<xsl:copy-of xml:space="preserve" select="@*"/>
					<xsl:apply-templates select="tr"/>
				</table>
			</xsl:otherwise>
			</xsl:choose>
	</xsl:template>

	<xsl:template match="tr">
		<xsl:choose>
			<xsl:when test="position() mod 2 = 0">
				<tr class="even {@class}">
					<xsl:apply-templates/>
				</tr>
			</xsl:when>
			<xsl:otherwise>
				<tr class="odd {@class}">
					<xsl:apply-templates/>
				</tr>
			</xsl:otherwise>

		</xsl:choose>
	</xsl:template>

	<xsl:template match="td">
		<td>
			<xsl:copy-of xml:space="preserve" select="@*"/>
			<xsl:apply-templates/>
		</td>
	</xsl:template>

	<xsl:template match="th">
		<th>
			<xsl:copy-of xml:space="preserve" select="@*"/>
			<xsl:apply-templates/>
		</th>
	</xsl:template>
	
	<xsl:template match="ul">
		<ul>
			<xsl:copy-of xml:space="preserve" select="@*"/> 
			<xsl:apply-templates/>
		</ul>
	</xsl:template>
	
	<xsl:template match="ol">
		<ol>
			<xsl:copy-of xml:space="preserve" select="@*"/> 
			<xsl:apply-templates/>
		</ol>
	</xsl:template>
	
	<xsl:template match="li">
		<li>
			<xsl:copy-of xml:space="preserve" select="@*"/> 
			<xsl:apply-templates/>
		</li>
	</xsl:template>
	
	<xsl:template match="strong">
		<strong><xsl:copy-of xml:space="preserve" select="@*"/> 
			<xsl:apply-templates/></strong>
	</xsl:template>

	<xsl:template match="a">
		<a href="{@href}" title="{@title}">
			<xsl:value-of select="."/>
		</a>
	</xsl:template>

	<xsl:template match="img">
		<xsl:choose>
			<xsl:when test="@type='local' and @usemap!=''">
				<img src="/babel-data/images/{//assessmentItem/@module}/{@src}" title="{@title}" usemap="{@usemap}"/>
			</xsl:when>
			<xsl:when test="@type='local'"> <!--and @height!=''"-->
				<img src="/babel-data/images/{//assessmentItem/@module}/{@src}">
<!--					<xsl:attribute name="src" select="concat('/babel-data/images/',//assessmentItem/@module,'/',@src)"/>-->
					<xsl:copy-of xml:space="preserve" select="@*[name(.) != 'src' and name(.) != 'type' ]"/>
					
				</img>
			</xsl:when>
			<!--<xsl:when test="@type='local'">
				<img src="/babel-data/images/{//assessmentItem/@module}/{@src}" title="{@title}" class="{@class}"/>
			</xsl:when>-->
			<xsl:otherwise>
				<img src="{@src}" title="{@title}" alt="{@alt}"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="cite">
		<cite>
			<xsl:apply-templates/>
		</cite>
	</xsl:template>
	
	<xsl:template match="em">
		<em>
			<xsl:apply-templates/>
		</em>
	</xsl:template>
	
	<xsl:template match="input">
		<input><xsl:copy-of xml:space="preserve" select="@*"/> </input>
	</xsl:template>
	
	<xsl:template match="iframe">
		<iframe>
			<xsl:copy-of xml:space="preserve" select="@*"/> 
		</iframe>
	</xsl:template>
	
	<xsl:template match="extLink">
		<a href="{@href}" target="_blank" title="{@title}">
			<xsl:value-of select="."/>
		</a>
	</xsl:template>

	<xsl:template match="check">
		<xsl:variable name="cname" select="@value"/>
		<p class="check">
			<input type="checkbox" name="{$cname}">
				<xsl:apply-templates/>
			</input>
		</p>
		<br/>
	</xsl:template>

	<xsl:template match="radio-group">
		<div class="radio-group">
			<xsl:call-template name="radio">
				<xsl:with-param name="group" select="@id"/>
				<xsl:with-param name="items" select="radio"/>
			</xsl:call-template>
		</div>
	</xsl:template>

	<xsl:template name="radio">
		<xsl:param name="group"/>
		<xsl:param name="items"/>
		<xsl:for-each select="$items">
			<input type="radio" name="{$group}">
				<xsl:apply-templates/>
			</input>
		</xsl:for-each>

	</xsl:template>

	<xsl:template match="newline">
		<br/>
	</xsl:template>

	<xsl:template match="clear">
		<div class="clearer"/>
	</xsl:template>


	<xsl:template match="break">
		<div class="break"/>
	</xsl:template>


	<!-- **************************************
		utility templates
		************************************** -->

	<xsl:template name="for.loop">
		<xsl:param name="content"/>
		<xsl:param name="i"/>
		<xsl:param name="count"/>
		
		<!--begin_: Line_by_Line_Output -->
		<xsl:if test="$i &lt;= $count">
			<xsl:value-of select='$content'/>
		</xsl:if>

		<!--begin_: RepeatTheLoopUntilFinished-->
		<xsl:if test="$i &lt;= $count">
			<xsl:call-template name="for.loop">
				<xsl:with-param name="content">
					<xsl:value-of select="$content"/>
				</xsl:with-param>
				<xsl:with-param name="i">
					<xsl:value-of select="$i + 1"/>
				</xsl:with-param>
				<xsl:with-param name="count">
					<xsl:value-of select="$count"/>
				</xsl:with-param>
			</xsl:call-template>
		</xsl:if>

	</xsl:template>
	
	<!--<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>-->
	
	<!--<xsl:template name="tablify">
		<xsl:variable name="bynode" select="by"/>
		<table>
			<tr><td>
				
			</td></tr>
		</table>
	</xsl:template>-->

</xsl:stylesheet>
